package net.melon.sso.utils;

import org.apache.commons.lang.StringUtils;

import net.esj.basic.utils.SecurityUtils;

public class PwdUtils {

	public static final String cryptWithTwiceSHA1(String pwd){
		String first = SecurityUtils.getSHA1(pwd);
		String sec = SecurityUtils.getSHA1(first);
		return sec;
	}
	
	public static final boolean checkPwd(String pwdInDb,String pwdFromClient,String nonce,String servertime){
		String tmp1 = SecurityUtils.getMD5(pwdFromClient);
		return StringUtils.equals(tmp1.toLowerCase(), pwdInDb.toLowerCase());
	}
	
	public static final boolean checkPwd(String pwdInDb,String pwdFromClient){
		String tmp1 = SecurityUtils.getMD5(pwdFromClient);
		return StringUtils.equals(tmp1.toLowerCase(), pwdInDb.toLowerCase());
	}
	
	public static final void main(String[] args){
		System.out.println(SecurityUtils.getMD5("123456"));
	}
}
